// EventsService.cs
// Facebook/Framework/Service
// Copyright (c) 2007, Nikhil Kothari. All Rights Reserved.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Facebook.Service.Core;

namespace Facebook.Service {

    /// <summary>
    /// Represents the service APIs that allow accessing event information.
    /// </summary>
    public sealed class EventsService {

        private FacebookSession _session;

        internal EventsService(FacebookSession session) {
            Debug.Assert(session != null);
            _session = session;
        }

        /// <summary>
        /// Gets the membership information for the specified event. This corresponds to the
        /// Facebook events.getMembers method.
        /// </summary>
        /// <param name="eventID">The unique ID of the event.</param>
        /// <returns>The list of members of the specified event.</returns>
        public EventMembership GetMembers(string eventID) {
            if (String.IsNullOrEmpty(eventID)) {
                throw new ArgumentNullException("eventID");
            }

            FacebookRequest request = new FacebookRequest(_session);
            request.Parameters["eid"] = eventID;

            FacebookResponse response = request.InvokeMethod("events.getMembers");
            if (response.Status == FacebookResponseStatus.Succeeded) {
                Debug.Assert(response.Result is Hashtable);

                return new EventMembership((Hashtable)response.Result);
            }

            return null;
        }
    }
}
